package com.yunxi.service.dubboService.impl.app;

import com.github.pagehelper.PageInfo;

import com.yunxi.app.pojo.VersionVO;
import com.yunxi.app.service.VersionDubboService;
import com.yunxi.model.app.Version;
import com.yunxi.service.localService.app.VersionService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * @version <1.0>
 * @Company <JINAN IAN SOFTWARE Co.,LTD.>
 * @Project <IAN Collaboration Suite>
 * @Author <zhangk>
 * @Date 2016/3/22
 * @description 应用商店 业务类
 */
@Service
public class VersionDubboServiceImpl  implements VersionDubboService {

    @Autowired
    @Qualifier(value = "versionServiceImpl")

    private VersionService versionService;


    /**
     * 获取最新版本
     *
     * @param type
     * @param platform
     */
    @Override
    public VersionVO getNewVersion(Integer type, String platform) throws Exception {
        return versionService.getNewVersion(type, platform);
    }


    @Override
    public VersionVO getById(Long id) throws InvocationTargetException, IllegalAccessException {
        Version version = versionService.getById(id);
        VersionVO versionVO = new VersionVO();
        BeanUtils.copyProperties(version,versionVO);
        return versionVO;
    }

    @Override
    public void saveOrUpdate(VersionVO versionVO) throws InvocationTargetException, IllegalAccessException {
        Version version =new Version();
        BeanUtils.copyProperties(versionVO,version);
        versionService.saveOrUpdate(version);
    }


    @Override
    public void removeById(Long id) {
        versionService.removeById(id);
    }


    @Override
    public PageInfo<VersionVO> findPageByVO(VersionVO vo, Integer pageNum, Integer pageSize) throws InvocationTargetException, IllegalAccessException {
        PageInfo<VersionVO> pageInfo = versionService.pageByVo(vo,pageNum,pageSize);
        return pageInfo;    }

    @Override
    public void removeByListVo(List<VersionVO> versionVOList) throws IllegalAccessException, InvocationTargetException, InstantiationException {
        versionService.removeByListVo(versionVOList);

    }

    @Override
    public List listByVo(VersionVO versionVO) {
        return versionService.listByVo(versionVO);
    }

}
